package com.ahstu.learning.learning;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

import com.ahstu.learning.R;


public class Course_Player extends Activity {
    /**
     * Called when the activity is first created.
     */
    private VideoView videoView;
    MediaController mMediaCtrl;


   

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.learning_player);
        videoView = (VideoView) findViewById(R.id.video_view);

        //init();
        videoView.start();

        //检测播放结束后自动跳出界面
        videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {

                try {
                    Thread.sleep(800);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    Toast.makeText(Course_Player.this, "视频播放异常！", Toast.LENGTH_SHORT)
                            .show();
                    e.printStackTrace();
                }
                finish();

                Toast.makeText(Course_Player.this, "视频播放结束！", Toast.LENGTH_SHORT).show();


            }
        });

    }

//    private void init() {
//        mMediaCtrl = new MediaController(Course_Player.this, false);
//        mMediaCtrl.setAnchorView(videoView);
//        mMediaCtrl.setMediaPlayer(videoView);
//        videoView.setMediaController(mMediaCtrl);
//        videoView.requestFocus();
//
//        File file = new File("/sdcard/diandixuetang/" + sum.file_name + ".mp4");
//        videoView.setVideoPath(file.getPath());
//
//    }
}
